package com.songhq.ctool.utils;

import com.intellij.notification.Notification;
import com.intellij.notification.Notifications;

import java.util.concurrent.TimeUnit;

public class NotificationThread  extends Thread{

    Notification notification;
    int sleepTime;


    NotificationThread(Notification notification, int sleepTime) {
        assert sleepTime > 0;
        this.notification = notification;
        // 默认4秒关闭弹窗
        this.sleepTime = sleepTime;
    }

    @Override
    public void run() {
        Notifications.Bus.notify(this.notification);
        try {
            TimeUnit.SECONDS.sleep(this.sleepTime);
        } catch (InterruptedException ignore) {
        }
        this.notification.expire();
    }


}
